import { app, BrowserWindow } from 'electron'
import { createWindow, toolMenu, buildMenu } from '@/main/buildWindow'
import { ipcEventListener } from '@/main/listenerEvent'


process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = 'true';

// 主进程就绪后创建窗口
app.whenReady().then(() => {
  ipcEventListener()

  // 创建主窗口
  const mainWin = createWindow()
  // 动态添加工具菜单
  toolMenu(mainWin)
  // 构建菜单
  buildMenu()

  app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})

// 窗口关闭处理
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit()
})
